#ifndef __COLLISION_H_
#define __COLLISION_H_

#include <algorithm>
#include <Windows.h>
#include "GlobalVariables.h"

struct Box
{
	int iX;//left
	int iY;//top
	int iWidth;//width
	int iHeight;//height
	float fVx;//veclocity x
	float fVy;//velocity y

	Box()
	{
		this->iX = 0;
		this->iY = 0;
		this->iWidth = 0;
		this->iHeight = 0;
		this->fVx = 0;
		this->fVy = 0;
	}

	Box(float iX, float iY, float iWidth, float iHeight, float fVx, float fVy)
	{
		this->iX = iX;
		this->iY = iY;
		this->iWidth = iWidth;
		this->iHeight = iHeight;
		this->fVx = fVx;
		this->fVy = fVy;
	}

	void SetPosition(int x, int y){ iX = x; iY = y; }
	void SetVelocity(float vx, float vy){ fVx = vx; fVy = vy; }
	void SetContent(int width, int height){ iWidth = width; iHeight = height; }
};

//
float sweptAABB(Box box1, Box box2, float &normalx, float &nomaly);

//
Box getSweptBroadphaseBox(Box box);

//
bool AABBCheck(Box box1, Box box2);

//
bool AABB(Box box1, Box box2, float &moveX, float &moveY);

//
bool isCollide(Box box, Box block, float &normalx, float &normaly);

#endif